package com.village.friend.mapper;

import com.village.friend.entity.User;
import com.village.friend.entity.UserLook;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 查看用户的记录 Mapper 接口
 * </p>
 *
 * @author yl
 * @since 2021-11-13
 */
public interface UserLookMapper extends BaseMapper<UserLook> {
    @Insert("insert into  user_look(user_id,user_id_looked,look_count)  values (#{userId},#{userIdLooked},1) on  duplicate key update  look_count=look_count+1, update_time=now()")
    Integer insertOrUpdate(Integer userId, Integer userIdLooked);

    List<User> getLookList(Integer userId, Integer offset, Integer limit);

    Integer getLookCount(Integer userId);

    @Select("select user_id userId,  user_id_looked userIdLooked,look_count lookCount ,create_time createTime,update_time updateTime from   user_look where user_id=#{userId} and  user_id_looked=#{userIdLooked} and update_time> concat(date(NOW()) ,' 00:00:00')  ")
    UserLook getLookUserToDay(Integer userId, Integer userIdLooked);
}
